package net.pimpas.web.jsf.components.ajax;

import javax.faces.component.UIComponent;

import net.pimpas.web.jsf.components.UIComponentPimpasBaseTag;

public abstract class UIAjaxTag extends UIComponentPimpasBaseTag {
	
	private String event;
	private String actionListener;
	private String render;
	private Boolean sendForm;
	private Boolean async;
	private Boolean immediate;
	private String control;
	
	@Override
	protected void setProperties(UIComponent component) {
		/*
		if(this.getParent() == null || !(this.getParent() instanceof UIComponentBase)) {
			try {
				throw new RuntimeException(ResourceBundleServiceProviderFactoryImpl.getResourceBundleServiceProvider()
				.getMessage(UIComponentPimpasBase.class, "wrongParent", ResourceBundleServiceProviderType.ERROR, "UIAjax", UIComponentBase.class.getName()));
			} catch (ResourceBundleNotFoundException e) {
			} catch (MessageKeyNotFoundException e) {
			}
		}
		*/
		UIAjax ajax = (UIAjax) component;
		ajax.setEvent(this.getEvent().toLowerCase());
		
		ajax.setActionListener( this.getActionListener() );
		ajax.setRender(this.getRender());
		ajax.setSendForm((this.getSendForm() == null) ? Boolean.TRUE : this.getSendForm());
		ajax.setAsync((this.getAsync()==null) ? Boolean.TRUE : this.getAsync());
		ajax.setImmediate((this.getImmediate()==null) ? Boolean.FALSE : this.getImmediate());
		ajax.setControl(this.getControl());
		
		super.setProperties(component);
	}

	public String getActionListener() {
		return actionListener;
	}

	public void setActionListener(String actionListener) {
		this.actionListener = actionListener;
	}

	public String getEvent() {
		return event;
	}
	public void setEvent(String event) {
		this.event = event;
	}

	public String getRender() {
		return render;
	}

	public void setRender(String render) {
		this.render = render;
	}

	public Boolean getSendForm() {
		return sendForm;
	}

	public void setSendForm(Boolean sendForm) {
		this.sendForm = sendForm;
	}

	public Boolean getAsync() {
		return async;
	}

	public void setAsync(Boolean async) {
		this.async = async;
	}

	public Boolean getImmediate() {
		return immediate;
	}

	public void setImmediate(Boolean immediate) {
		this.immediate = immediate;
	}

	public String getControl() {
		return control;
	}

	public void setControl(String control) {
		this.control = control;
	}
}